<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.name" placeholder="权限名称"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="search">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="pageInfo.rows"
              highlight-current-row v-loading="listLoading"
              style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
			<el-table-column prop="name" label="权限名称" width="150" sortable>
			</el-table-column>
			<el-table-column prop="url" label="路径" width="200" :show-overflow-tooltip="true" sortable>
			</el-table-column>
			<el-table-column prop="desc" label="描述" :show-overflow-tooltip="true" width="250" sortable>
			</el-table-column>
			<el-table-column prop="sn" label="唯一标识" :show-overflow-tooltip="true" width="250" sortable>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination layout="total,sizes,prev, pager, next"
                     @size-change="handleSizeChange"
                     @current-change="handleCurrentChange"
                     :current-page="query.currentPage"
                     :page-sizes="[5, 10, 50, 100]"
                     :page-size="10"
                     :total="pageInfo.total"
                     style="float:right;">
			</el-pagination>
		</el-col>

	</section>
</template>

<script>
	export default {
		data() {
			return {
				filters: {
					name: ''
				},
        department:{},
        pageInfo:{
          rows: [],
          total: 0,
        },
				listLoading: false,
        //列表选中列
				sels: [],
        // 查询体
        query:{
          currentPage:1,
          pageSize:10,
          keyword:null
        },
			}
		},
		methods: {
      // 高级查询
      search(){
        this.query.currentPage = 1;
        this.getDepartments();
      },
      // 单页大小转换
      handleSizeChange(val){
        this.query.pageSize=val;
        this.query.currentPage=1;
        this.getDepartments();
      },
      // 页面跳转
			handleCurrentChange(val) {
        this.query.currentPage = val;
				this.page = val;
				this.getDepartments();
			},
			// 获取权限分页列表
			getDepartments() {
        this.query.keyword = this.filters.name;
        this.$http.post("/permission",this.query).then(result=>{
          result = result.data;
          if(result.success){
            this.pageInfo = result.object;
          } else {
            this.$message({type:"error",message:"查询失败"+result.message})
          }
        }).catch(() => {
          this.$message({type:"error",message:"网络错误"})
        })
			},
		},
		mounted() {
      this.getDepartments();
    }
	}

</script>

<style scoped>

</style>